var t = require("../../utils/api.js"), a = (require("../../utils/disapi.js"), getApp());

Page({
    data: {
        optionList: [ {
            status: 1,
            name: "用户自提"
        }, {
            status: 2,
            name: "团长配送"
        } ],
        showLoding: !1,
        noMore: !1
    },
    onLoad: function(o) {
        var e, n, s = this, r = o.status, i = wx.getSystemInfoSync(), d = s.data.optionList;
        this.setData({
            showLoding: !1,
            currentTab: o.status || "1",
            containerHeight: i.windowHeight - Math.round(i.windowWidth / 375 * 55)
        }), wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        });
        for (var g = 0; g < d.length; g++) r == d[g].status && (n = g);
        t.AfterHeadgetGoodsList({
            openid: a.globalData.openid,
            type: r
        }).then(function(t) {
            console.log(t), 0 == t.errno ? (e = t.data.length < 10 ? 0 : 2, s.setData({
                data: t.data,
                page: e,
                status: r
            })) : s.setData({
                data: [],
                page: 0,
                noMore: !0
            }), s.setData({
                showLoding: !0,
                curCode: n
            });
        });
    },
    switchNav: function(t) {
        var a = this, o = t.currentTarget.dataset.current, e = a.data.optionList;
        console.log(t);
        for (var n, s = 0; s < e.length; s++) o == e[s].status && (n = s);
        a.setData({
            currentTab: o,
            curCode: n,
            status: o
        }), console.log(a.data.curCode);
    },
    bindChange: function(o) {
        var e = this, n = o.detail.current, s = e.data.optionList;
        console.log(n);
        for (var r, i, d = 0; d < s.length; d++) n == d && (r = s[d].status);
        e.setData({
            currentTab: r,
            showLoding: !1,
            data: [],
            noMore: !1
        }), console.log(e.data.currentTab), t.AfterHeadgetGoodsList({
            openid: a.globalData.openid,
            type: r
        }).then(function(t) {
            console.log(t), 0 == t.errno ? (i = t.data.length < 10 ? 0 : 2, e.setData({
                data: t.data,
                page: i,
                status: r
            })) : e.setData({
                data: [],
                page: 0,
                noMore: !0
            }), e.setData({
                showLoding: !0
            });
        });
    },
    getCurrentList: function(o) {
        var e = this;
        e.setData({
            loading: !0,
            tip: ""
        }), console.log(e.data.currentTab);
        var n = e.data.page, s = e.data.status;
        if (0 == n) return e.setData({
            loading: !1
        }), !1;
        t.AfterHeadgetGoodsList({
            openid: a.globalData.openid,
            type: s,
            page: n
        }).then(function(t) {
            if (console.log(t), 0 == t.errno) {
                t.data.length < 10 ? n = 0 : n += 1;
                var a = e.data.data.concat(t.data);
                e.setData({
                    data: a,
                    page: n,
                    status: s,
                    loading: !1
                });
            } else e.setData({
                page: 0,
                data: e.data.data,
                loading: !1
            });
        });
    },
    viewDetail: function(t) {
        wx.navigateTo({
            url: "./groupOrderDetail?id=" + t.currentTarget.dataset.id
        });
    }
});